﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SynoManager.GUI;

namespace SynoManager.DownloadStation.Plugins
{
    public partial class FolderWatcherOptionsPanel : PreferencesPanel
    {
        private readonly FolderWatcher watcher;

        public FolderWatcherOptionsPanel()
        {
            InitializeComponent();
        }

        public FolderWatcherOptionsPanel(FolderWatcher watcher)
            : this()
        {
            this.watcher = watcher;

            pathTextBox.Text = watcher.Path;
            deleteCheckBox.Checked = watcher.DeleteOnAccept;
        }

        public override void Save()
        {
            watcher.Path = pathTextBox.Text;
            watcher.DeleteOnAccept = deleteCheckBox.Checked;
        }

        private void browseButton_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                pathTextBox.Text = folderBrowserDialog.SelectedPath;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            pathTextBox.Text = String.Empty;
        }
    }
}
